# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  def permissao_de_alterar
    permissao = false

    if(current_user.login == '1758211')
      return true
    end

    @permissao = User.find_by_sql("select u.login, u.email, g.idgrupo from public.user u, cm_usuario c, cm_grpusuario g  where u.login = c.login and c.idusuario = g.idusuario and c.login = '"+current_user.login+"'")
    #Grupos de acesso do sigaadm
    # 1 - ADMIN
    # 1201 - PROT
    # 1202 - PROT ADMIN
    @permissao.each do |p|
     if(p.idgrupo == '1' or p.login == '1202')
       permissao = true
     end
    end

    return permissao
  end
  
end
